﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StockDataGeter
{
    public partial class FrmViewDataLocation : Form
    {
        public FrmViewDataLocation()
        {
            InitializeComponent();
        }

        private void btnView_Click(object sender, EventArgs e)
        {
            string strWebContent = Tool.GetContentFromUrll("http://vol.stock.hexun.com/idio_01.aspx?stockcode=000004");
            WebBrowser webb1 = new WebBrowser();
            webb1.Navigate("about:blank");
            HtmlDocument htmldoc1 = webb1.Document.OpenNew(true);

            int start1 = strWebContent.IndexOf("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">", StringComparison.CurrentCultureIgnoreCase);
            //int start1 = strWebContent.IndexOf(" <?xml version=\"1.0\" encoding=\"gb2312\"?>");
            //start1 = strWebContent.IndexOf("<TABLE border=\"1\" borderColorDark=\"#ffffff\" bordercolorlight=\"#CCCCCC\" cellPadding=\"0\" cellSpacing=\"0\" width=\"98%\" xmlns:ms=\"urn:schemas-microsoft-com:xslt\">", start1 + 10);
            //start1 = strWebContent.IndexOf("<TABLE border=\"1\" borderColorDark=\"#ffffff\" bordercolorlight=\"#CCCCCC\" cellPadding=\"0\" cellSpacing=\"0\" width=\"98%\" xmlns:ms=\"urn:schemas-microsoft-com:xslt\">", start1 + 10);
            //start1 = strWebContent.IndexOf("<TABLE border=\"1\" borderColorDark=\"#ffffff\" bordercolorlight=\"#CCCCCC\" cellPadding=\"0\" cellSpacing=\"0\" width=\"98%\" xmlns:ms=\"urn:schemas-microsoft-com:xslt\">", start1 + 10);
            //start1 = strWebContent.IndexOf("<TABLE border=\"1\" borderColorDark=\"#ffffff\" bordercolorlight=\"#CCCCCC\" cellPadding=\"0\" cellSpacing=\"0\" width=\"100%\">", start1 + 10);
        
            int end1 = strWebContent.IndexOf("</table>", start1 + 100);
            string content1 = strWebContent.Substring(start1, end1 - start1 + 8);
            htmldoc1.Write(content1);

            string str1 = htmldoc1.GetElementsByTagName("TR")[5].GetElementsByTagName("TD")[1].InnerText;

            MessageBox.Show(str1.ToString());
        }
    }
}
